#include <bits/stdc++.h>
using namespace std;
struct node {
    int d,v,a,tips;
    double point;
};
struct node1{
    int fr,en;
};

bool cmp(node1 x,node1 y){
    return x.fr<y.fr;
}
node car[100050];
int tests[100050];
bool h[100050];
node1 related[100050];
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T;
    cin>>T;
    while (T!=0){
        int n,m,L,V;
        cin>>n>>m>>L>>V;
        for (int i=1;i<=n;i++){
            cin>>car[i].d>>car[i].v>>car[i].a;
            if (car[i].v<=V&&car[i].a<=0) car[i].tips=-1;
            if (car[i].v>V&&car[i].a>=0) car[i].point=car[i].d;
            if (car[i].v<=V&&car[i].a>0){
                car[i].point=(V*V-car[i].v*car[i].v)/car[i].a/2+car[i].d;
                if (car[i].point!=int(car[i].point)) car[i].point=int(car[i].point)+1;
                if (car[i].point>L) car[i].tips=-1;
            }
            if (car[i].v>V&&car[i].a<0){
                int ta=-car[i].a;
                car[i].point=(car[i].v*car[i].v-V*V)/ta/2+car[i].d;
                car[i].point=int(car[i].point);
                if (car[i].point>L) car[i].point=L;
            }
        }
        for (int i=1;i<=m;i++){
            cin>>tests[i];
            h[tests[i]]=1;
        }
        /*for (int i=1;i<=n;i++){
            cout<<car[i].d<<" "<<car[i].point<<endl;
        }*/
        int ans=0;
        bool flag=0;
        for (int i=1;i<=n;i++){
            if (car[i].tips==-1){
                continue;
            }
            if (car[i].a>=0){
                for (int j=car[i].point;j<=L;j++){
                    if (h[j]==1&&flag==0){
                        ans++;
                        flag=1;
                        related[i].fr=j;
                    }
                    if (h[j]==1&&flag==1){
                        related[i].en=max(related[i].en,j);
                    }
                }
                flag=0;
            }
            if (car[i].a<0){
                for (int j=car[i].d;j<=car[i].point;j++){
                    if (h[j]==1&&flag==0){
                        ans++;
                        flag=1;
                        related[i].fr=j;
                    }
                    if (h[j]==1&&flag==1){
                        related[i].en=max(related[i].en,j);
                    }
                }
                flag=0;
            }
        }
        /*for (int i=1;i<=n;i++){
            cout<<related[i].fr<<" "<<related[i].en<<endl;
        }*/
        sort(related+1,related+n+1,cmp);
        int ans1=1;
        for (int i=2;i<=n;i++){
            if (related[i].fr!=0&&related[i-1].en!=0){
                if (related[i].fr>related[i-1].en) ans1++;
                else{
                    related[i].en=min(related[i].en,related[i-1].en);
                }
            }
        }

        cout<<ans<<" "<<m-ans1<<endl;
        T--;
        for (int i=1;i<=m;i++){
            h[i]=0;
            tests[i]=0;
        }
        for (int i=1;i<=n;i++){
            car[i].tips=0;
            car[i].point=0;
            related[i].fr=0;
            related[i].en=0;
            car[i].d=0;
            car[i].v=0;
            car[i].a=0;
            car[i].tips=0;
            car[i].point=0;
        }
    }

    return 0;
}
